import { Ajax } from '../utils/http';

export class NewsService {
    private startdate: string;
    private enddate: string;
    private page: number;
    constructor(_startdate: string, _enddate: string, _page: number) {
        this.startdate = _startdate;
        this.enddate = _enddate;
        this.page = _page;
    }

    public async send(): Promise<NewsData> {
        let response: NewsData;
        let data = {
            startdate: this.startdate,
            enddate: this.enddate,
            articletype: 1,
            p: this.page,
            psize: 12
        }
        try {
            response = await new Ajax<NewsData>('/article/articleList', data).post();
        } catch (e) {
            throw e;
        }
        return response;
    }
}


/*List*/
export interface NewsItem {
    id: string;
    title: string;
    abstract: string;
    thumb: string;
    content: string;
    viewcount: string;
    collectcount: string;
    likecount: string;
    createtime: string;
    isdetail: string;
    isfollow: number;
    islike: number;
  }
  
  /*Data*/
  export interface NewsData {
    list: NewsItem[];
    total: number;
  }
  
